package cn.z2huo.knowledge.function.functionprogram.parallel;

import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

/**
 * <p>
 *
 * @author z2huo
 */
public class ParallelDiceRolls {

    public static final int N = 100000000;

    private final double fraction;

    public ParallelDiceRolls() {
        fraction = 1.0 / N;
    }

    public static void main(String[] args) {

    }

    public Map<Integer, Double> parallelDiceRolls() {
//        return IntStream.range(0, N).parallel()
//                .mapToObj(twoDiceThrows())
//                .collect(Collectors.groupingBy(side -> Collectors.summarizingDouble(n -> fraction)));
        return null;
    }

    private int twoDiceThrows() {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        int firstThrow = random.nextInt(1, 7);
        int secondThrow = random.nextInt(1, 7);
        return firstThrow + secondThrow;
    }

}
